#!/bin/bash -x

#echo "Waiting for tests to finish"
#i=2;
#sleep 1;
#while [  $i -ge 2 ]; do
#       sleep 1;
#        i=`ps aux | grep "./tests.sh" | wc -l`;
#done

echo "Tests are finished cleaning up."

ssh -p $SGNL_INITIATOR_PORT root@$SGNL_INITIATOR  'bash -s' < kill.sh "$SGNL_HIPFW $SGNL_HIPFW_OPTIONS\$"
ssh -p $SGNL_INITIATOR_PORT root@$SGNL_INITIATOR  'bash -s' < kill.sh "$SGNL_HIPD $SGNL_HIPD_OPTIONS\$"
ssh -p $SGNL_RESPONDER_PORT root@$SGNL_RESPONDER 'bash -s' < kill.sh "$SGNL_HIPFW $SGNL_HIPFW_OPTIONS\$"
ssh -p $SGNL_RESPONDER_PORT root@$SGNL_RESPONDER 'bash -s' < kill.sh "$SGNL_HIPD $SGNL_HIPD_OPTIONS\$"
if [ $SGNL_HIPFW_MBOX_OPTIONS ]; then
    ssh -p $SGNL_MBOX1_PORT root@$SGNL_MBOX   'bash -s' < kill.sh "$SGNL_HIPFW $SGNL_HIPFW_MBOX_OPTIONS\$"
fi
if [ $SGNL_HIPFW_MBOX2_OPTIONS ]; then
    ssh -p $SGNL_MBOX2_PORT root@$SGNL_MBOX2   'bash -s' < kill.sh "$SGNL_HIPFW $SGNL_HIPFW_MBOX2_OPTIONS\$"
fi
